package com.gccloud.design;

import com.gccloud.design.dto.BwpBusinessProcessDto;
import com.gccloud.design.service.ProcessCustomService;
import com.gccloud.starter.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 流程定制
 *
 * @author guo.wang
 **/
@Api(tags = "流程定制")
@RestController
@RequestMapping("/processCustom")
public class ProcessCustomController {

    @Resource
    private ProcessCustomService processCustomService;

    @ApiOperation("流程定制树")
    @PostMapping(value = "/getProcessTree")
    public R<List<Map<String, Object>>> getProcessTree(@RequestParam("id") Integer id) {
        return R.success(processCustomService.getProcessTree(id));
    }

    @ApiOperation("新增或修改流程")
    @PostMapping(value = "/insertOrUpdateProcess")
    public R<Integer> insertOrUpdateProcess(@RequestBody BwpBusinessProcessDto bwpBusinessProcessDto) {
        return R.success(processCustomService.insertOrUpdateProcess(bwpBusinessProcessDto));
    }

    @ApiOperation("删除流程")
    @PostMapping(value = "/deleteProcess/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public R<String> deleteProcess(@PathVariable Integer id) {
        return R.success(String.valueOf(processCustomService.deleteProcess(id)));
    }
}
